﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using D2D2.SharedInterfaces.Networking;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace D2D2.Core.SpriteManager
{
    public class DropManagerClient
    {
        private List<Drop> _drops = new List<Drop>();
 
        public void Update(Drop drop)
        {
            if (!_drops.Exists(d => d.Id == drop.Id))
                _drops.Add(drop);
        }

        public void Update(GameTime gameTime)
        {
            float elapsed = (float) gameTime.ElapsedGameTime.TotalSeconds;

            _drops = _drops.FindAll(d => d.State != DropState.EndMotion);
            _drops.ForEach(d => d.Update(elapsed));
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            _drops.ForEach(d => d.Draw(spriteBatch));
        }
    }
}
